
#ifndef __CMD_H_
#define __CMD_H_


#define MAX_CMD_LINE_LEN                     256
#define MAX_CMD_ARG_NUM                      16

#define SYS_HELP_CMD_WIDTH                   10

#define LYNXI_MCU_CMD_LINE_PROMPT            "[MCU CMD] > "
#define CMD_FLAG_REPEAT                      1

typedef struct cmd_tbl_s
{
	const char *name;
	int maxargs;
	int repeatable;
	int (*func)(struct cmd_tbl_s *, int, int, char * const []);
	const char *usage;
	const char *help;
}cmd_tbl_t;

#define __used	__attribute__((__used__))
#define Struct_Section __attribute__((__section__(".command.mcu")))

#define LYNXI_MCU_CMD_MKENT(name,maxargs,rep,func,usage,help) \
				{#name,maxargs,rep,func,usage,help}
				
#define LYNXI_MCU_CMD(name,maxargs,rep,func,usage,help) \
				static const cmd_tbl_t __lx_mcu_cmd##name __used Struct_Section = {#name, maxargs, rep,func, usage, help}

void lx_mcu_cli_main_loop(void);
				
int cmd_usage(cmd_tbl_t *cmdtp);
cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len);	

#endif
